package com.rentong.wx.cust.controller;

import com.rentong.common.R;
import com.rentong.wx.cust.dto.CustGuanzhuDto;
import com.rentong.wx.cust.dto.CustGuanzhuVo;
import com.rentong.wx.cust.service.CustGuanzhuService;
import com.rentong.wx.utils.WxApiUtil;
import io.swagger.annotations.ApiImplicitParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author zhangle
 * @email 459343178@qq.com
 * @date 2024-12-24 14:42:32
 */
@RestController
public class CustGuanzhuController {

    @Autowired
    private CustGuanzhuService custGuanzhuService;

    //103、我的关注或我的粉丝
    @GetMapping("/custGuanzhu/getCustGuanzhuList/{type}")
    @ApiImplicitParam(name = "type", value = "1:我的关注 2:我的粉丝")
    public R getCustGuanzhuList(@PathVariable("type") Integer type, HttpServletRequest request) throws Exception {
        Long custId = WxApiUtil.getCurrentCustId(request);
        List<CustGuanzhuVo> custGuanzhuList = custGuanzhuService.getCustGuanzhuList(type, custId);
        return R.success(custGuanzhuList);
    }

    //104、关注或取消关注
    @PostMapping("/custGuanzhu/custGuanzhu")
    public R custGuanzhu(CustGuanzhuDto custGuanzhuDto, HttpServletRequest request) throws Exception {
        Long custId = WxApiUtil.getCurrentCustId(request);
        custGuanzhuService.custGuanzhu(custId, custGuanzhuDto);
        return R.success();
    }

}
